package com.qubuyer.business.mine.adapter

import com.qubuyer.R
import com.qubuyer.databinding.ItemSaleAmountDetailBinding
import com.qubuyer.repository.entitys.SaleAmountDetail
import com.qubuyer.utils.StringUtil
import com.qubyer.widget.adapter.BindingRvAdapter

/**
 * @author Susong
 * @date 创建时间2019/4/3
 * @description 销售总额adapter
 */
class SaleAmountAdapter(private val mType: Int) : BindingRvAdapter<SaleAmountDetail,ItemSaleAmountDetailBinding>(){

    override val itemLayout: Int
        get() = R.layout.item_sale_amount_detail

    override fun onBind(data: SaleAmountDetail, dataBinding: ItemSaleAmountDetailBinding) {
        dataBinding.tvGoodName.text = data.order?.order_goods?.getOrNull(0)?.goods_name
        dataBinding.tvGoodPrice.text = StringUtil.formatAmount(data.order?.order_goods?.getOrNull(0)?.goods_price,2)
        dataBinding.tvTime.text = ""
        val stringBuilder = StringBuilder()
        if (mType == 1) {
            stringBuilder.append("收益:¥")
        } else {
            stringBuilder.append("待结算,预计收益:¥")
        }
        stringBuilder.append(StringUtil.formatAmount(data.distribut_money.toDouble(), 2))
        dataBinding.tvAnticipatedIncome.text = stringBuilder.toString()
    }
}